import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams,ViewController  } from 'ionic-angular';
import { TabsPage } from '../tabs/tabs';
import { SettingPage } from '../setting/setting';
import { MineEditPage } from '../personal/mine-edit/mine-edit';
import {UsersService} from '../../providers/users.service';
import { Storage } from '@ionic/storage';
import { PersonalOwnerHousesPage } from '../personal-owner-houses/personal-owner-houses';
import { PersonalOwnerToAgreePage } from '../personal-owner-to-agree/personal-owner-to-agree';
import { PersonalOwnerAgreedPage } from '../personal-owner-agreed/personal-owner-agreed';
import { PersonalOwnerDonePage } from '../personal-owner-done/personal-owner-done';
import {PersonalUserAgreedPage} from '../personal-user-agreed/personal-user-agreed';
import {PersonalUserDonePage} from '../personal-user-done/personal-user-done';
import {PersonalUserFocusPage} from '../personal-user-focus/personal-user-focus';
import {PersonalUserToAgreePage} from '../personal-user-to-agree/personal-user-to-agree';


/**
 * Generated class for the PersonalPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-personal',
  templateUrl: 'personal.html',
  providers:[UsersService]

})
export class PersonalPage {
  userInfo;
  userId;
  userName:any;
  token;
  user;
  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public viewCtrl: ViewController,
    private userSer:UsersService,
    private storage:Storage,


  ) {


  }

  ionViewWillEnter() {
  }
  ionViewDidLoad() {
    let that = this;

    // that.userName = that.storage.get('userName');
    that.storage.ready().then(() =>{
      that.storage.get('user').then((user) =>{
        that.user = user;
        console.log(that.user);

        that.userSer.getUserInfo(user,function (result) {
          that.userInfo = result[0];
          console.log(that.userInfo)
        })
      });

    })
  }

  back(){
    this.viewCtrl.dismiss({flag:true});

    // this.navCtrl.push(TabsPage);
  }
  edit() {
    console.log(this.userInfo);
    this.navCtrl.push(MineEditPage,{"userInfo":this.userInfo,"user":this.user});
  }
  toSetting(){
    this.navCtrl.push(SettingPage);
  }



  ownerHouses(){
    this.navCtrl.push(PersonalOwnerHousesPage);
  }

  ownerToAgree(){
    console.log("owner")
    this.navCtrl.push(PersonalOwnerToAgreePage);
  }

  ownerAgreed(){
    this.navCtrl.push(PersonalOwnerAgreedPage);
  }

  ownerDone(){
    console.log("owner")
    this.navCtrl.push(PersonalOwnerDonePage);
  }

  userFocus(){
    this.navCtrl.push(PersonalUserFocusPage);
  }

  userToagree(){
    this.navCtrl.push(PersonalUserToAgreePage);
}

  userAgreed(){
    this.navCtrl.push(PersonalUserAgreedPage);
  }

  userDone(){
    this.navCtrl.push(PersonalUserDonePage);
  }

}
